<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/index/css/style.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/index/css/LArea.min.css" />
	<script type="text/javascript" src="__STATIC__/index/js/rem.js"></script>
	<title>{if $Think.get.id}新增收货地址{else}编辑收货地址{/if}</title>
</head>
<body class="whiteBg">
  <div class="new_address">
  	 <div class="address_form">
  	 	<!--收货人姓名-->
  	 	<div class="form_list">
  	 		<span>收货人姓名</span>
  	 		<input id="name" type="text" name="name" value="{$db.name ?: ''}" placeholder="请输入姓名" />
  	 	</div>
  	 	<!--手机号码-->
  	 	<div class="form_list">
  	 		<span>手机号</span>
  	 		<input id="phone" type="tel" name="phone" value="{$db.phone ?: ''}" placeholder="请输入手机号码" maxlength="11" />
  	 	</div>
  	 	<!--所在区域-->
  	 	<div class="form_list">
  	 		<span>所在区域</span>
  	 		<input id="ipt" type="text" name="area" value="{$db.area ?: ''}" placeholder="请选择所在区域" readonly="" />
  	 		<input type="hidden" id="value2"/>
            <input type="hidden" id="default">
            <i class="form_arrow"></i>
  	 	</div>
  	 	<!--详细地址-->
  	 	<div class="form_list">
  	 		<span>详细地址</span>
  	 		<input id="address" type="text" name="address" value="{$db.address ?: ''}" placeholder="请填写详细地址" />
  	 	</div>
  	 </div>

  	 <!--保存btn-->
  	 <div class="save">
  	 	<button>保存</button>
  	 </div>
  </div>
<script type="text/javascript" src="__STATIC__/index/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="__STATIC__/index/js/LArea.js"></script>
<script type="text/javascript" src="__STATIC__/index/js/LAreaData1.js"></script>
<script type="text/javascript" src="__STATIC__/index/js/LAreaData2.js"></script>
<script type="text/javascript" src="__STATIC__/index/js/layer/mobile/layer.js"></script>
<script type="text/javascript">
	//匹配iOS 失去焦点
	$("#ipt").focus(function() {
      document.activeElement.blur();
    });
    var area = new LArea();
      area.init({
          'trigger':'#ipt',
          'valueTo':'#value2',
          'defaultval':'#default',
          'keys': {
              id: 'value',
              name:'text'
          },
          'type':2,
          'data': [provs_data,citys_data,dists_data]
      });
      area.value=[18,0,3];
    //验证表单
    $('.save').on('click',function(){
    	if ($('#name').val() == '') {
    		layer.open({
    			content:'联系人不能为空',
    			skin:'msg',
    			time:2
    		})
    	}else if($('#phone').val() == ''){
    		layer.open({content:'手机号码不能为空',skin:'msg',time:2})
    	}else if ($('#ipt').val() == '') {
    		layer.open({content:'所在地区不能为空',skin:'msg',time:2})
    	}else if($('#address').val() == ''){
    		layer.open({content:'详细地址不能为空',skin:'msg',time:2})
    	}else{
    	    $.ajax({
				url:"",
				type:"POST",
				data:$('input').serialize(),
				success:function (res) {
				    if(res=='ok'){
                        layer.open({
                            content:'保存成功',
                            skin:'msg',
                            time:2,
                            end:function(){
                                window.location.href = 'javascript:history.back()'
                            }
                        })
					}

                }
			})

    	}
    })
</script>
</body>
</html>